package com.alipay.app.groupmeal.standard.ui;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

import androidx.appcompat.app.AppCompatActivity;

import com.alipay.app.groupmeal.standard.R;

public class SysSetActivity extends AppCompatActivity {

    private EditText apiEd;
    private Button submitBut;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_sys_set);
        apiEd = findViewById(R.id.apiEd);
        apiEd.setText("http://192.168.0.:7900/");
        submitBut = findViewById(R.id.submitBut);
        submitBut.setOnClickListener(view -> {
            String api = apiEd.getText().toString();
            if (api == null || "".equals(api)) {
                Toast.makeText(this, "不能为空", Toast.LENGTH_LONG).show();
                return;
            }
            SharedPreferences userInfo = getSharedPreferences("sysCost", MODE_PRIVATE);
            SharedPreferences.Editor editor = userInfo.edit();
            editor.putString("api", api);
            editor.commit();
            Toast.makeText(this, "请重新启动", Toast.LENGTH_LONG).show();
            System.exit(0);
        });
    }
}
